package com.sk.weichat.bean.redpacket;

import android.os.Parcel;
import android.os.Parcelable;

import com.j256.ormlite.field.DatabaseField;
import com.j256.ormlite.table.DatabaseTable;

/**
 * @author lzs
 * @date 2019/10/9
 * Email:343067508@qq.com
 **/
@DatabaseTable(tableName = "red_packet_notice_msg")
public class RedPacketNoticeBean implements Parcelable, Comparable<RedPacketNoticeBean> {
    public static final String RED_PACKET_NOTICE = "RedPacketNotice_MSG";

    public static final int read = 1;
    public static final int unRead = 0;
    /**
     * fromUserName : 谢丹
     * msgType : 0
     * fileSize : 0
     * fromUserId : 10000003
     * timeSend : 1568690547
     * messageId : 2d0d307d6d134645bfc8a1d9ed3cd49f
     * toUserName : 测试顶顶顶
     * type : 86
     * toUserId : 10000002
     * content : 恭喜发财，大吉大利
     * objectId : {"title":"红包退款","refundTime":1568690547,"source":"群聊-哈哈哈哈","reason":"超时未领取","money":1.2,"redId":"5d63801757cd0e5a8cf3df49"}
     */
    @DatabaseField(generatedId = true)
    private int _id;

    @DatabaseField(defaultValue = "")
    private String fromUserName;
    @DatabaseField
    private int msgType;
    @DatabaseField
    private int fileSize;
    @DatabaseField(defaultValue = "")
    private String fromUserId;
    @DatabaseField
    private int timeSend;
    @DatabaseField(defaultValue = "")
    private String messageId;
    @DatabaseField(defaultValue = "")
    private String toUserName;
    @DatabaseField
    private int type;
    @DatabaseField(defaultValue = "")
    private String toUserId;
    @DatabaseField(defaultValue = "")
    private String content;
    @DatabaseField(defaultValue = "")
    private String objectId;
    @DatabaseField
    private int isRead;//是否已读 0,未读 1一度

    private RedPacketNoticeInfoBean redPacketNoticeInfoBean;


    protected RedPacketNoticeBean(Parcel in) {
        _id = in.readInt();
        fromUserName = in.readString();
        msgType = in.readInt();
        fileSize = in.readInt();
        fromUserId = in.readString();
        timeSend = in.readInt();
        messageId = in.readString();
        toUserName = in.readString();
        type = in.readInt();
        toUserId = in.readString();
        content = in.readString();
        objectId = in.readString();
        isRead = in.readInt();
        redPacketNoticeInfoBean = in.readParcelable(RedPacketNoticeInfoBean.class.getClassLoader());
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(_id);
        dest.writeString(fromUserName);
        dest.writeInt(msgType);
        dest.writeInt(fileSize);
        dest.writeString(fromUserId);
        dest.writeInt(timeSend);
        dest.writeString(messageId);
        dest.writeString(toUserName);
        dest.writeInt(type);
        dest.writeString(toUserId);
        dest.writeString(content);
        dest.writeString(objectId);
        dest.writeInt(isRead);
        dest.writeParcelable(redPacketNoticeInfoBean, flags);
    }

    @Override
    public int describeContents() {
        return 0;
    }

    public static final Creator<RedPacketNoticeBean> CREATOR = new Creator<RedPacketNoticeBean>() {
        @Override
        public RedPacketNoticeBean createFromParcel(Parcel in) {
            return new RedPacketNoticeBean(in);
        }

        @Override
        public RedPacketNoticeBean[] newArray(int size) {
            return new RedPacketNoticeBean[size];
        }
    };

    public int getIsRead() {
        return isRead;
    }

    public void setIsRead(int isRead) {
        this.isRead = isRead;
    }

    public RedPacketNoticeBean() {
    }


    public String getFromUserName() {
        return fromUserName;
    }

    public void setFromUserName(String fromUserName) {
        this.fromUserName = fromUserName;
    }

    public int getMsgType() {
        return msgType;
    }

    public void setMsgType(int msgType) {
        this.msgType = msgType;
    }

    public int getFileSize() {
        return fileSize;
    }

    public void setFileSize(int fileSize) {
        this.fileSize = fileSize;
    }

    public String getFromUserId() {
        return fromUserId;
    }

    public void setFromUserId(String fromUserId) {
        this.fromUserId = fromUserId;
    }

    public int getTimeSend() {
        return timeSend;
    }

    public void setTimeSend(int timeSend) {
        this.timeSend = timeSend;
    }

    public String getMessageId() {
        return messageId;
    }

    public void setMessageId(String messageId) {
        this.messageId = messageId;
    }

    public String getToUserName() {
        return toUserName;
    }

    public void setToUserName(String toUserName) {
        this.toUserName = toUserName;
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    public String getToUserId() {
        return toUserId;
    }

    public void setToUserId(String toUserId) {
        this.toUserId = toUserId;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public String getObjectId() {
        return objectId;
    }

    public void setObjectId(String objectId) {
        this.objectId = objectId;
    }

    public int get_id() {
        return _id;
    }

    public void set_id(int _id) {
        this._id = _id;
    }

    public RedPacketNoticeInfoBean getRedPacketNoticeInfoBean() {
        return redPacketNoticeInfoBean;
    }

    public void setRedPacketNoticeInfoBean(RedPacketNoticeInfoBean redPacketNoticeInfoBean) {
        this.redPacketNoticeInfoBean = redPacketNoticeInfoBean;
    }

    @Override
    public String toString() {
        return "RedPacketNoticeBean{" +
                "_id=" + _id +
                ", fromUserName='" + fromUserName + '\'' +
                ", msgType=" + msgType +
                ", fileSize=" + fileSize +
                ", fromUserId='" + fromUserId + '\'' +
                ", timeSend=" + timeSend +
                ", messageId='" + messageId + '\'' +
                ", toUserName='" + toUserName + '\'' +
                ", type=" + type +
                ", toUserId='" + toUserId + '\'' +
                ", content='" + content + '\'' +
                ", objectId='" + objectId + '\'' +
                ", isRead=" + isRead +
                ", redPacketNoticeInfoBean=" + redPacketNoticeInfoBean +
                '}';
    }

    @Override
    public int compareTo(RedPacketNoticeBean o) {
        return o.getTimeSend() - timeSend;
    }
}
